﻿using System.Web;
using CustomerAssistant.Core;
using CustomerAssistant.DAL;
using Itour.Models;
using System;
using System.IO;

namespace CustomerAssistantWebServer
{
    public class GetVerClientHandle : IClientHandle
    {
        public IClientHandle NextNode
        {
            get;
            set;
        }

        public string RequestKey
        {
            get { return "getmd5"; }
        }

        public void Response(HttpRequest Request, Stream OutputStream)
        {
            if (string.Compare(Request[Util.REQUEST_KEY], RequestKey, true) == 0)
            {
                using (StreamWriter sw = new StreamWriter(OutputStream))
                {
                    sw.Write(Util.FileMd5_hash(System.Web.HttpContext.Current.Server.MapPath("~/CustomerAssistantSetup.msi")));
                    sw.Flush();
                }


            }
            else
            {
                if (NextNode != null)
                    NextNode.Response(Request, OutputStream);
            }
        }
    }
}